var _n50;
var cc__extends = __extends;
var cc__awaiter = __awaiter;
var cc__generator = __generator;
var cc__importDefault = __importDefault;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var def_bundleManager = function (t) {
  function _ctor() {
    // 初始化管理对象
    const manager = t.call(this) || this; // 调用 t 并确保上下文

    // 设置管理器的基本属性
    manager._managerName = "bundle管理";
    manager.length = 0;

    // 初始化 Bundles
    manager.bundList = {
      frameBundle: null,
      soundBundle: null,
      home: null,
      loadingPage: null
    };

    // 定义需要加载的 Bundle 列表
    manager.bundleLoadList = ["frameBundle", "soundBundle", "loadingPage", "home"];

    // 执行初始化方法
    manager._Initialize();

    return manager;

  }
  cc__extends(_ctor, t);
  _ctor.prototype._Initialize = function () {
    // 调用初始化方法
    t.prototype._Initialize.call(this);

    // 计算 bundleLoadList 的长度，并更新 length 属性
    this.length = this.bundleLoadList.length; // 直接获取长度

  };
  _ctor.prototype.getLength = function () {
    return this.length;
  };
  Object.defineProperty(_ctor.prototype, "BundleList", {
    get() {
      return this.bundList;
    },
    enumerable: false,
    configurable: true
  });
  _ctor.prototype.loadAllBundle = function (t) {
    return cc__awaiter(this, undefined, undefined, function () {
      var e;
      var o;
      var n;
      var i;
      return cc__generator(this, function (r) {
        switch (r.label) {
          case 0:
            e = 0;
            r.label = 1;
          case 1:
            if (e < this.bundleLoadList.length) {
              o = this.bundleLoadList[e];
              n = this.bundList;
              i = o;
              return [4, this.loadOnceBundle(o, o)];
            } else {
              return [3, 4];
            }
          case 2:
            n[i] = r.sent();
            t && t();
            console.debug(o);
            r.label = 3;
          case 3:
            e++;
            return [3, 1];
          case 4:
            return [2];
        }
      });
    });
  };
  _ctor.prototype.loadOnceBundle = function (t, e) {
    return new Promise(function (o, n) {
      var i = {};
      cc.assetManager.loadBundle(t, i, function (r, a) {
        if (r) {
          console.error("bundle (name:" + e + "path :" + t + ") 加载出错!!", r);
          return void cc.assetManager.loadBundle(t, i, function (i, r) {
            if (i) {
              console.error("bundle (name:" + e + "path :" + t + ") 加载出错2!!", i);
              return void n(null);
            }
            o(r);
          });
        }
        o(a);
      });
    });
  };
  return _ctor;
}(cc__importDefault(require("zqcc_frameNamespace")).default.zqcc_ManagerBase);
exports.default = def_bundleManager;